/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * TelaPrincipal.java
 *
 * Created on 08/04/2012, 19:16:36
 */

package br.edu.fatec.ads.view;

import br.edu.fatec.ads.util.FrameUtil;
import javax.swing.JInternalFrame;

/**
 *
 * @author Ubirajara
 */
public class TelaPrincipal extends javax.swing.JFrame {

    /** Creates new form TelaPrincipal */
    public TelaPrincipal() {
        initComponents();

        FrameUtil.getInstance().centralizarFrame(this);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        barFerramentas = new javax.swing.JToolBar();
        btnBiblioteca = new javax.swing.JButton();
        btnPessoa = new javax.swing.JButton();
        btnAcesso = new javax.swing.JButton();
        formularioPane = new javax.swing.JDesktopPane();
        menuBar = new javax.swing.JMenuBar();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Faculdade de Tecnologia da Baixada Santista");
        setResizable(false);

        barFerramentas.setRollover(true);
        barFerramentas.setBorderPainted(false);
        barFerramentas.setPreferredSize(new java.awt.Dimension(100, 96));

        btnBiblioteca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/fatec/ads/image/library-books-icone-5837-96.png"))); // NOI18N
        btnBiblioteca.setFocusable(false);
        btnBiblioteca.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnBiblioteca.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnBiblioteca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBibliotecaActionPerformed(evt);
            }
        });
        barFerramentas.add(btnBiblioteca);

        btnPessoa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/fatec/ads/image/person.png"))); // NOI18N
        btnPessoa.setFocusable(false);
        btnPessoa.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnPessoa.setMaximumSize(new java.awt.Dimension(96, 96));
        btnPessoa.setMinimumSize(new java.awt.Dimension(96, 96));
        btnPessoa.setPreferredSize(new java.awt.Dimension(96, 96));
        btnPessoa.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnPessoa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPessoaActionPerformed(evt);
            }
        });
        barFerramentas.add(btnPessoa);

        btnAcesso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/edu/fatec/ads/image/home-home-icone-6491-96.png"))); // NOI18N
        btnAcesso.setToolTipText("Permissões de Acesso");
        btnAcesso.setFocusable(false);
        btnAcesso.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAcesso.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnAcesso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAcessoActionPerformed(evt);
            }
        });
        barFerramentas.add(btnAcesso);

        barFerramentas.setBounds(0, 0, 800, 95);
        desktopPane.add(barFerramentas, javax.swing.JLayeredPane.DEFAULT_LAYER);

        formularioPane.setMinimumSize(new java.awt.Dimension(800, 500));
        formularioPane.setBounds(0, 100, 800, 500);
        desktopPane.add(formularioPane, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menuBar.setPreferredSize(new java.awt.Dimension(0, 20));
        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnBibliotecaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBibliotecaActionPerformed
        this.adicionarFormularios(new FrameBiblioteca(), " Menu - Biblioteca");
    }//GEN-LAST:event_btnBibliotecaActionPerformed

    private void btnPessoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPessoaActionPerformed
        this.adicionarFormularios(new FramePessoa(), " Menu - Pessoa");
    }//GEN-LAST:event_btnPessoaActionPerformed

    private void btnAcessoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAcessoActionPerformed
        this.adicionarFormularios(new FrameAcesso(), " Menu - Acesso");
    }//GEN-LAST:event_btnAcessoActionPerformed

    public void adicionarFormularios(JInternalFrame frame, String titulo){
        this.formularioPane.removeAll();

        frame.setSize(this.formularioPane.getSize());
        frame.setResizable(!rootPaneCheckingEnabled);

        this.formularioPane.add(frame);
        this.setTitle("Faculdade de Tecnologia da Baixada Santista");
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToolBar barFerramentas;
    private javax.swing.JButton btnAcesso;
    private javax.swing.JButton btnBiblioteca;
    private javax.swing.JButton btnPessoa;
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JDesktopPane formularioPane;
    private javax.swing.JMenuBar menuBar;
    // End of variables declaration//GEN-END:variables

}
